package org.fjala.softure.tree;

import java.util.List;

/**
 * Base interface to build a node for a tree.
 *
 * @author Dann Meneses
 */
public interface Node<T> {

    /**
     * Returns the data contained in the node.
     *
     * @return data in the node.
     */
    T getData();
    
    /**
     * Sets the data that contained the node.
     */
    void setData(T t);

    /**
     * Returns the child collection of the node.
     *
     * @return child collection.
     */
    List<Node<T>> getChildren();

    /**
     * Returns parent of the node.
     * 
     * @return parent of the node.
     */
    Node<T> getParent();
    
    /**
     * Set the parent of the node.
     * 
     * @param parent new parent of the node.
     */
    void setParent(Node<T> parent);

    /**
     * Tells when a node have children.
     * 
     * @return True if the node has children.
     */
    boolean hasChildren();
    
    /**
     * Adds a child for the node. If the node is full of children delegates the 
     * task to his children.
     * 
     * @param child child that will be added..
     */
    void addChild(Node<T> child);
    
    /**
     * Removes a child for the node.
     *
     * @param child child that will be removed.
     */
    void removeChild(Node<T> child);

    /**
     * Return the child count of the node.
     * 
     * @return the child count of the node.
     */
    public int getChildCount();
}
